package edu.cmu.cs.stage3.alice.authoringtool.viewcontroller;

import edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources;

/**
 * @author Jason Pratt
 */
public class StringPropertyLabel extends PropertyLabel {

 public StringPropertyLabel( edu.cmu.cs.stage3.alice.core.property.StringProperty property ) {
  super( property );
 }

 //Rem @Override
 public void update () {
  String propertyName = ((edu.cmu.cs.stage3.alice.core.property.StringProperty)property).getStringValue();
  // System.out.println("StringPropertyLabel.java: update()");
  if( (property.getOwner() instanceof edu.cmu.cs.stage3.alice.core.response.PropertyAnimation) && property.getName().equals( "propertyName" ) ) {
   edu.cmu.cs.stage3.alice.core.Element element = ((edu.cmu.cs.stage3.alice.core.response.PropertyAnimation)property.getOwner()).element.getElementValue();
   if( element != null ) {
    Class elementClass = element.getClass();
    while( edu.cmu.cs.stage3.alice.core.Element.class.isAssignableFrom( elementClass ) ) {
     String propertyKey = elementClass.getName() + "." + propertyName;
     if( AuthoringToolResources.getName( propertyKey ) != null ) {
      propertyName = AuthoringToolResources.getName( propertyKey );
      // System.out.println(propertyKey+": "+propertyName);
      break;
     }
     elementClass = elementClass.getSuperclass();
    }
   }
  }
  setText( propertyName );
 }

}
